package com.sds.shop.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sds.fw.mvc.Action;
import com.sds.fw.mvc.HttpUtil;
import com.sds.shop.dao.ProductDAO;
import com.sds.shop.vo.ProductVO;

public class ProductEditAction extends Action {
	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		String path;
		ProductDAO dao = new ProductDAO();
		ProductVO vo = new ProductVO();
		String prd_no = request.getParameter("prd_no");
		vo.setPrdNo(prd_no);
		vo.setPrdNm(request.getParameter("prd_nm"));
		vo.setCategoryNo(request.getParameter("category_no"));
		vo.setPrdDes(request.getParameter("prd_des"));
		vo.setSellPrcUnit(Integer.parseInt(request.getParameter("sell_prc_unit")));
		vo.setSellStartDt(request.getParameter("sell_start_dt"));
		vo.setSellEndDt(request.getParameter("sell_end_dt"));
		vo.setDlvConstraint(request.getParameter("dlv_constarint"));
		vo.setAsFlg(request.getParameter("as_flg"));
		vo.setReturnFlg(request.getParameter("return_flg"));
		vo.setImgOrgFileNm(request.getParameter("img_org_file_nm"));
		vo.setImgGenFileNm(request.getParameter("img_gen_file_nm"));
		vo.setRegId(request.getParameter("reg_id"));
		vo.setRegDtm(request.getParameter("reg_dtm"));		
		dao.editProduct(prd_no, vo);
		
		request.setAttribute("ProductEdit", vo);
		path = "/jsp/productedit.jsp";
		HttpUtil.forward(request, response, path);
	}

}
